home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / PopUpFormatter / StringList.h < prev    next >
Text File  |  1995-06-12  |  4KB  |  88 lines

  1. // Format: 80 columns, tabs = 4 spaces
  2. #import <appkit/appkit.h>
  3.  
  4. /******************************************************************************
  5.     StringList - by Jeff Martin
  6.  
  7.     StringList (a subclass of Storage) is a convenient way to deal with lists of character strings. It contains methods for adding strings, inserting strings, sorting strings and searching for strings.
  8.         
  9.     StringList can also add strings from a delimited string (such as the ones passed to an app by the workspace). The delimiters can be supplied or assumed to be white space.
  10.     
  11.     Finally, StringList implements a browser delegate method so that it can easily display itself if set to be a browser delegate.
  12.  
  13.     To use this object inside of InterfaceBuilder, simply drag its icon from the palettes window into the suitcases window. Then drag in a browser and set its delegate to be the stringlist. Type in some entries into StringList's inspector and test interface. The browser fills up!
  14.  
  15. Written by: Jeff Martin (jmartin@next.com)
  16. You may freely copy, distribute and reuse the code in this example.  
  17. Don't even talk to me about warranties.
  18. ******************************************************************************/
  19.     
  20. @interface StringList : Storage
  21. {
  22.     BOOL    isSorted;            // Whether or not the list is currently sorted
  23. }
  24.  
  25. - initCount:(unsigned) count;
  26.  
  27. // Convenience adding methods (defaulting to ifAbsent=NO, noCopy=NO, 
  28. //        sorted=NO and at=count)
  29. - addString:(const char *)string;
  30. - addStringIfAbsent:(const char *)string;
  31. - addStringNoCopy:(const char *)string;
  32. - addStringIfAbsentNoCopy:(const char *)string;
  33.  
  34. - addString:(const char *)string at:(int)at;
  35. - addStringIfAbsent:(const char *)string at:(int)at;
  36. - addStringNoCopy:(const char *)string at:(int)at;
  37. - addStringIfAbsentNoCopy:(const char *)string at:(int)at;
  38.  
  39. - addStringSorted:(const char *)string;
  40. - addStringIfAbsentSorted:(const char *)string;
  41. - addStringNoCopySorted:(const char *)string;
  42. - addStringIfAbsentNoCopySorted:(const char *)string;
  43.  
  44. // The main adding method (all other adds call this)
  45. - addString:(const char *)string ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy sorted:(BOOL)sorted at:(int)at;
  46.  
  47. // Adding Multiple strings
  48. - addStrings:(const char *const*)strings;
  49. - addStrings:(const char *const*)strings ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy sorted:(BOOL)sorted at:(int)at;
  50.  
  51. // Adding another StringList
  52. - addStringList:stringListObject;
  53. - addStringList:stringListObject ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy sorted:(BOOL)sorted at:(int)at;
  54.  
  55. // Adding individual strings from delimited (tab or otherwise) string
  56. - addDelimitedStrings:(const char *)string delimiters:(const char *)dels;
  57. - addDelimitedStrings:(const char *)string delimiters:(const char *)dels ifAbsent:(BOOL)ifAbsent sorted:(BOOL)sorted at:(int)at;
  58.  
  59. // Finding strings in list
  60. - (const char *const*)strings;
  61. - (const char *)stringAt:(int)at;
  62.  
  63. // Finding the index of a given string and/or whether it is in list
  64. - (BOOL)stringExists:(const char *)string;
  65. - (unsigned)indexOfString:(const char *)string;
  66. - (unsigned)indexOfString:(const char *)string exists:(BOOL *)exists;
  67.  
  68. // Removing strings from list
  69. - removeString:(const char *)string;
  70. - removeStrings:(const char *const*)strings;
  71. - (char *)removeStringAt:(int)at;
  72.  
  73. // Sorting list
  74. - (BOOL)isSorted;
  75. - sortStrings:sender;
  76.  
  77. // Archiving
  78. - write:(NXTypedStream *)stream;
  79. - read:(NXTypedStream *)stream;
  80.  
  81. // Cleanup
  82. - freeStrings;
  83. - free;
  84.  
  85. // Bonus NXBrowser support
  86. - (int)browser:sender fillMatrix:matrix inColumn:(int)column;
  87.  
  88. @end